jq(".expenseAll")[0].addEventListener("tap",function(){
    Supp.TreeList.hideAll();
});
jq(".showAll")[0].addEventListener("tap",function(){
    Supp.TreeList.showAll();
});

jq(".supp-sub-btn")[0].addEventListener("tap",function(){
    Supp.TreeList.resetList();
});
jq(".supp-main-btn")[0].addEventListener("tap",function(){
    var data = Supp.TreeList.getList();
    closeWindow(data);
});
function closeWindow(data){
    if (data.length !=0) {
        var returnVal = {};
        returnVal["deptName"] = data[0].text;
        returnVal["deptId"] = data[0].value;
        appcan.window.publish("deptTree",returnVal);               
    }
    appcan.window.close();
}
var setting = {
    check: {
        chkStyle: "radio"
    }  
};
var treeId = "deptTree";

var mobileProxy = "/service/mobile/proxy/r/service/eip/company/getTreeData";
//var mobileProxy = "data/dept1.json";
Supp.ajax({
    url : mobileProxy,
    dataType : "json",
    type: 'post',
    data:{"showpost":0},
    success : function(resp){
        if (resp != undefined){
            var sNodes = Supp.TreeList.transferDate(resp.rows);
            Supp.TreeList.init("#"+treeId,setting,sNodes);
            Supp.TreeList.showAll();
            appcan.ready(function(){
                var val = Supp.LocStorage.getVal("checkedVal");
                val = JSON.parse(val);
                for (var key in val) {
                    jq("#"+val[key]).prop("checked","true");
                }
            });
        }
    },
    error : function(error){
       console.log(error);
    }              
});      